package com.nanhang.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nanhang.booksearch.BookIS0;
import com.nanhang.booksearch.BookS0;
import com.nanhang.entity.Bookborrow;
import com.nanhang.entity.Bookinfo;
import com.nanhang.mapper.BookinfoMapper;
import com.nanhang.service.IBookinfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import util.PageResult;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ymm
 * @since 2025-01-09
 */
@Service
public class BookinfoServiceImpl extends ServiceImpl<BookinfoMapper, Bookinfo> implements IBookinfoService {
    @Override
    public PageResult<Bookinfo> search(Integer page, Integer pagesize, BookIS0 BIS0){
        QueryWrapper<Bookinfo> re =new QueryWrapper<>();
        re.like(StrUtil.isNotBlank(BIS0.getBname()),"bname",BIS0.getBname());
        re.like(StrUtil.isNotBlank(BIS0.getPublisher()),"publisher",BIS0.getPublisher());
        re.like(StrUtil.isNotBlank(BIS0.getStatus()),"status",BIS0.getStatus());

        Page<Bookinfo> repage = this.page(new Page<>(page,pagesize),re);

        return new PageResult<>(repage.getRecords(),repage.getTotal());
    }
}
